Vehicles are subjected to various types of control by an electronic control unit (hereafter referred to as “ECU”). Such control includes engine-related control of an air fuel ratio, fuel injection amount, and emission as well as body-related control for a power window, an air bag, and an ABS. The ECU provides various types of control for the vehicle based on current conditions and traveling conditions of the vehicle sensed by various sensors mounted on the vehicle.
The ECU comprises a central processing unit (CPU), a ROM (Read Only Memory) that stores programs and data to be executed, a RAM (Random Access Memory) which provides a work area for execution and which stores results of computation, and an I/O interface for receiving signals from various sensors and transmitting control signals to various parts of the engine.
A system wherein a rewritable and non-volatile memory, such as a flash memory, an EEPROM, or an EPROM, is used as the ROM to allow a program or data to be rewritten through serial communication is known. Such a system typically comprises a rewriting device, an ECU and a serial communication path connecting them together. Rewriting is achieved by deleting data stored in the rewritable memory mounted on the ECU and writing new data transferred from the rewriting device via serial communication into the memory. By way of example, Japanese Patent Application Laid-Open No. 63-223901 describes a method for changing a program stored in the EEPROM of the ECU in response to a request from an external device via a SCI (Serial Communication Interface) terminal with the ECU being mounted on the vehicle.
Generally, deleting and writing operation on a non-volatile memory such as a flash memory and EEPROM requires a relatively large amount of time. The ECU may be busy during deleting or writing operation. As a result, the ECU may not be able to respond to the rewriting device. When there is no response from the ECU for a predetermined period, the rewriting device determines that communication between the ECU and the rewriting device is offline.
FIGS. 5 and 6 show a typical method for rewriting a program stored in a memory of the ECU. FIG. 5 is a flow chart showing the process performed by the rewriting device, and FIG. 6 is a flow chart showing the process performed by the ECU.
In response to a request for deleting operation from the rewriting device (501), the ECU sends a signal to the rewriting device indicative of start of deleting operation (552) and deletes a program stored in a memory of the ECU (553). In response to the signal indicative of start of deleting operation, the rewriting device requests the result of the deleting operation (505). If the deleting operation has not been completed, the ECU sends a signal to the rewriting device indicating that the deleting operation is in progress (556). If the deleting operation has been completed, the ECU sends a signal indicative of completion of the deleting operation (557).
Similarly, writing operation is carried out. In response to a request for writing operation from the rewriting device (521), the ECU sends a signal to the rewriting device indicative of start of writing operation (562) and writes a new program to the memory of the ECU (563). In response to the signal indicative of start of writing operation, the rewriting device requests the result of the writing operation (525). If the writing operation has not been completed, the ECU sends a signal to the rewriting device indicating that the writing operation is in progress (566). If the writing operation has been completed, the ECU sends a signal indicative of completion of the writing operation (567).
At step 509 or 529, if the response from the ECU indicates that the deleting or writing operation is in progress, the process returns to step 505 or 525. If the response from the ECU indicates that the deleting or writing operation has been completed, the process proceeds to the following step 510 or 530. In this way, the rewriting device determines whether deleting or writing operation is being performed or has been completed by sending a request for the result of the deleting or writing operation and by receiving a response to the request. Even if the deleting or writing operation is being performed, an erroneous determination of offline is not made as long as there is a response from the ECU.
FIG. 7 shows typical two forms of a non-volatile memory mounted on the ECU. FIG. 7A shows a form in which a flash memory 216, which is a non-volatile memory, is provided independently of a CPU 214. In other words, the flash memory 216 is mounted on a chip different from the CPU 214. The flash memory 216 is coupled to a chip of a microcomputer where the CPU is mounted via an external bus 205. When the ECU 210 receives a request for deleting or writing operation on the flash memory 216 from the rewriting device 211, the operation is performed by an input/output controller (not shown) that controls input/output through the external bus 205. In this way, since delete or write control on the flash memory 216 is performed independently of the CPU, the CPU does not become busy during deleting or writing operation.
FIG. 7B shows another form in which the flash memory 216 and the CPU 214 are provided on a single chip to constitute one chip microcomputer. The flash memory 216 is coupled to the CPU 214 via an internal bus 207. Deleting or writing operation is performed by an interface means incorporated in the CPU 214 as a function. In this case, the CPU may become busy during deleting or writing operation. When the CPU is busy, the ECU 210 may be unable to communicate with the rewriting device 211.
Recently, in order to reduce costs relating to the ECU, a microcomputer including a non-volatile memory, as shown in FIG. 7B, has been increasingly employed. As described above, in this form, a CPU may become busy during deleting or writing operation on a non-volatile memory. When the ECU is busy, it may not respond to a request for the result of deleting or writing operation from the rewriting device. As a result, even though communication between the ECU and the rewriting device is normal, the rewriting device may determine that the communication is offline if a response from the ECU have not been received in a predetermined period. Thus, when the CPU of the ECU is busy, the rewriting device may made an erroneous determination of offline.